package com.hzlj.position.locate.converter;

import cn.hutool.core.date.DateUtil;
import com.fz.common.base.core.OneFieldTimesUtil;
import com.hzlj.position.locate.common.model.ReportInitiative;

import java.util.Date;

/**
 * 通信联络核查-人脸签到(ReportInitiative)DTO转换类
 *
 * @author lifh
 * @date 2023-07-24 16:15:32
 */
public class ReportInitiativeConverter {
    public static void setReportTimesFlag(ReportInitiative old,
                                          ReportInitiative update,
                                          Date reportTime) {
        int hour = DateUtil.hour(reportTime, true);
        int splitLength = 6;
        int totalSplit = 6;
        int index = hour % 6;

        if (hour < 6) {
            update.setReportTimesFlag6(
                    OneFieldTimesUtil.plusOne(old.getReportTimesFlag6(), splitLength, totalSplit, index, false)
            );
        } else if (hour < 12) {
            update.setReportTimesFlag12(
                    OneFieldTimesUtil.plusOne(old.getReportTimesFlag12(), splitLength, totalSplit, index, false)
            );
        } else if (hour < 18) {
            update.setReportTimesFlag18(
                    OneFieldTimesUtil.plusOne(old.getReportTimesFlag18(), splitLength, totalSplit, index, false)
            );
        } else {
            update.setReportTimesFlag24(
                    OneFieldTimesUtil.plusOne(old.getReportTimesFlag24(), splitLength, totalSplit, index, false)
            );
        }
    }
}
